package reflect;

import annotation.LovoAnnotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

/**
 *
 */
public class Test02 {
    public static void main(String[] args) {
        Student student = new Student();
        Date date = new Date();
        Class studentClass = student.getClass();
        if(studentClass.isAnnotationPresent(LovoAnnotation.class)){
            LovoAnnotation annotation = (LovoAnnotation) studentClass.getAnnotation(LovoAnnotation.class);
            System.out.println(annotation.value());
            System.out.println(Arrays.toString(annotation.likes()));
        }
        Field[] fields = studentClass.getDeclaredFields();
        for(int i = 0;i < fields.length;i++){
            if(fields[i].isAnnotationPresent(LovoAnnotation.class)){
                LovoAnnotation lovoAnntation = fields[i].getAnnotation(LovoAnnotation.class);
                System.out.println(lovoAnntation.value());
                System.out.println(Arrays.toString(lovoAnntation.likes()));
            }
        }

    }
}
